﻿<?php
	//РЕДАГУВАННЯ СВОГО ПРОФИЛЮ!!!
	//HZ
	function editor_profile(){//форма редагування новини
		$query="SELECT username, id, email, mobile, login, personal_file FROM user WHERE id = '{$_SESSION['id']}';";
		$res=mysql_query($query);
		$row=mysql_fetch_array($res);
		$up_username = $row['username'];
		$up_email = $row['email'];
		$up_id = $row['id'];
		$up_mobile = $row['mobile'];
		$up_personal_file = $row['personal_file'];
		
		$GLOBALS['h1'] = "Редактирование своего профиля {$row['login']}";
		$GLOBALS['content'] = <<<HTML
		<div class="row-fluid">
			<div class="span6">
				<form class="well form-inline" method="POST" action="/?action=edit_profile_do">
					<div class="row-fluid">
						<label>E-mail</label>
						<input type="text" name="email" class="span12" value="{$up_email}"/>
					</div>
					<div class="row-fluid">
						<label>ФИО</label>
						<input type="text" name="username" class="span12" value="{$up_username}"/>
					</div>
					<div class="row-fluid">
						<label>Телефон</label>
						<input type="text" name="mobile" class="span12" value="{$up_mobile}"/>
					</div>
					<div class="row-fluid">
						<label>Личное дело</label>
						<textarea rows="10" class="span12" name="personal_file">{$up_personal_file}</textarea>
					</div>
					
					<div class="row-fluid">
						<button type="submit" class="btn">Сохранить изменения</button>
						<input type="hidden" name="id" value="{$up_id}"/>
					</div>
				</form>
			</div>
		</div>
HTML;
	}
	
	function edit_profile_do(){//редагування юзера
		$strSQL = 'UPDATE user SET username = "'.$_POST["username"].'", email = "'.$_POST["email"].'", mobile = "'.$_POST['mobile'].'", personal_file = "'.$_POST['personal_file'].'" WHERE id = "'.$_POST['id'].'"';
		mysql_query($strSQL);
		header('Location: /?action=editor_profile', true, 303);
	}
	//HZ
	//END PROFILE

	//ФУНКЦИЯ ВИВОДУ ФОРМИ "СДЕЛАЛ - НЕ СДЕЛАЛ"
	function what(){
		
		$GLOBALS['h1']='Что сделано или почену не сделал';
		$GLOBALS['content'] = <<<HTML
		<form method="post" action="?action=what_do"> 
			<div class="row-fluid">
				<div class="span6">
					<textarea name="what_master" class="span12" style="height:150px;" ></textarea>
					<input type="hidden" name="id" value="{$_GET['id']}">
				</div>
			</div>
			<div class="row-fluid">
				<div style="text-align:right;" class="span6">
					<input type="submit" class="btn btn-large btn-info" value="Сохранить"/>
				</div>
			</div>
					
	</form>
		
HTML;
	}
	
	function what_do(){//додатково
		$what_master = $_POST['what_master'];
		$id = $_POST['id'];
		
		$query = 'UPDATE orders SET what_master="'.$what_master.'" WHERE id="'.$id.'"';
		$result = mysql_query($query) or die(mysql_error());
		
		header("Location: /?action=my_table", true, 303);
	}
	//
	
	//ФУНКЦІЯ РЕДАКТИРОВАНИЯ ПОЛЯ "ЧТО С АПАРАТОМ"
	function edit_what_aparat_do(){//ajax редактирование поля что с апаратом
		$query = 'SELECT what_aparat, id_master FROM orders WHERE id = "'.$_GET['id'].'"';
		$res=mysql_query($query);
		$row=mysql_fetch_array($res);
		
		if($row['id_master'] == $_SESSION['id']){
			$all_bug = $row['what_aparat'].$_GET['newdop'];
			$strSQL = 'UPDATE orders SET what_aparat = "'.$all_bug.'" WHERE id = "'.$_GET['id'].'"';
			mysql_query($strSQL);
			echo $_GET['newdop'];
		}
		exit();
	}
	//END!!

	function take_bool(){//взять заказ
		$date_admision_remont = time();
		$strSQL = 'UPDATE orders SET id_master = "'.$_SESSION['id'].'", date_admision_remont = "'.$date_admision_remont.'" WHERE service="'.$_SESSION['sc'].'" AND id = "'.$_GET['id'].'"';
		mysql_query($strSQL);

		header("Location: /?action=my_table", true, 303);
	}
	
	function do_bool(){//готово сделано
		$date_end_remont = time();
		$query = "SELECT points_r FROM orders WHERE id = {$_GET['id']}";
		$sql = mysql_query($query);
		$row = mysql_fetch_array($sql);
		
		$query2 = "SELECT points FROM user WHERE id = {$_SESSION['id']}";
		$sql2 = mysql_query($query2);
		$row2 = mysql_fetch_array($sql2);
	
		$b = $row2['points'] + $row['points_r'];
		$strSQL = 'UPDATE orders SET date_end_remont = "'.$date_end_remont.'", bool_ready = "1" WHERE service="'.$_SESSION['sc'].'" AND id = "'.$_GET['id'].'"';
		$strSQL1 = 'UPDATE user SET points = "'.$b.'" WHERE id = "'.$_SESSION['id'].'"';
		mysql_query($strSQL);
		mysql_query($strSQL1);
		
		header("Location: /?action=what&id={$_GET['id']}", true, 303);
	}
	
	function dont_bool(){//готово не сделано
		$date_end_remont = time();
		$strSQL = 'UPDATE orders SET date_end_remont = "'.$date_end_remont.'", bool_ready = "2" WHERE service="'.$_SESSION['sc'].'" AND id = "'.$_GET['id'].'"';
		mysql_query($strSQL);

		header("Location: /?action=what&id={$_GET['id']}", true, 303);
	}
	
	function history(){//история
		$GLOBALS['h1'] = "Моя история";
		$date = time();
		$query = "SELECT * FROM orders WHERE bool_ready!='0' AND ({$date}-date_end_remont<=2592000) AND id_master ={$_SESSION['id']}";
		$sql = mysql_query($query) or die(mysql_error());
		
		$GLOBALS['content'] .= '
		<h3 class="heading">За месяц</h3>
		<div class="row-fluid">
			<table class="table table-bordered">
			<thead> 
				<tr style="text-align:center;">
					<th>Статус</th>
					<th>№ заказа</th>
					<th>№ в базе</th>
					<th>Сц</th>
					<th>Модель</th>
					<th>Стоимость</th>
					<th>Балы в рублях</th>
					<th>Что с аппаратом</th>
					<th>Дата приема</th>
					<th>Дата окончания</th>
					<th>Срочно</th>
					<th>Что сделал/не сделал</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
		';
			
		while($row = mysql_fetch_array($sql)){
			$quickly = 'Нет';
			if($row['bool_quickly'] == 1) {$quickly = 'Да';}
			
			$date = date('d.m.Y H:i', $row['date_admision_remont']);
			if ($row['date_admision_remont'] == 0) {$date = '-';}
			
			$date_end = date('d.m.Y H:i', $row['date_end_remont']);
			if ($row['date_end_remont'] == 0) {$date_end = '-';}
			
			$userlink = get_user_link($row['who_gave']);
			if ($row['who_gave'] == 0) {$userlink = '-';}
			$userlink_man = get_user_link($row['id_menedger']);
			if ($row['id_menedger'] == 0) {$userlink_man = '-';}
			$userlink_mast = get_user_link($row['id_master']); 
			if ($row['id_master'] == 0) {$userlink_mast = '-';}
			
			$status = get_status($row);
			
			$GLOBALS['content'] .= <<<TPL
			<tr>
				<td>{$status}</td>
				<td>{$row['numb_order']}<br />{$row['client_name']}</td>
				<td>{$row['numb_order_base']}</td>
				<td>{$row['service']}</td>
				<td>{$row['model']}</td>
				<td>{$row['price']}</td>
				<td>{$row['points_r']}</td>
				<td>{$row['what_aparat']}</td>
				<td>{$date}</td>
				<td>{$date_end}</td>
				<td>{$quickly}</td>
				<td>{$row['what_master']}</td>
				<td>
					Менеджер: {$userlink_man}<br/>
					Мастер: {$userlink_mast}<br/>
					Выдал: {$userlink}
				</td>
			</tr>		
TPL;
		}

		$date = time();
		$query = "SELECT * FROM orders WHERE bool_ready!='0' AND ({$date}-date_end_remont<=31536000) AND id_master ={$_SESSION['id']}";
		$sql = mysql_query($query) or die(mysql_error());
	
		$GLOBALS['content'] .= '</tbody></table></div><h3 class="heading">За год</h3>';
		$GLOBALS['content'] .= '
		<div class="row-fluid">
		<table class="table table-bordered">
			<thead> 
				<tr style="text-align:center;">
					<th>Статус</th>
					<th>№ заказа</th>
					<th>№ в базе</th>
					<th>Сц</th>
					<th>Модель</th>
					<th>Стоимость</th>
					<th>Балы в рублях</th>
					<th>Что с аппаратом</th>
					<th>Дата приема</th>
					<th>Дата окончания</th>
					<th>Срочно</th>
					<th>Что сделал/не сделал</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
		';

		while($row = mysql_fetch_array($sql)){
			$quickly = 'Нет';
			if($row['bool_quickly'] == 1) {$quickly = 'Да';}
			
			$date = date('d.m.Y H:i', $row['date_admision']);
			if ($row['date_admision'] == 0) {$date = '-';}
			
			$date_end = date('d.m.Y H:i', $row['date_end_remont']);
			if ($row['date_end_remont'] == 0) {$date_end = '-';}
			
			$userlink = get_user_link($row['who_gave']);
			if ($row['who_gave'] == 0) {$userlink = '-';}
			$userlink_man = get_user_link($row['id_menedger']);
			if ($row['id_menedger'] == 0) {$userlink_man = '-';}
			$userlink_mast = get_user_link($row['id_master']); 
			if ($row['id_master'] == 0) {$userlink_mast = '-';}
			
			
			$status = get_status($row);
			
			$GLOBALS['content'] .= <<<TPL
			<tr>
				<td>{$status}</td>
				<td>{$row['numb_order']}<br />{$row['client_name']}</td>
				<td>{$row['numb_order_base']}</td>
				<td>{$row['service']}</td>
				<td>{$row['model']}</td>
				<td>{$row['price']}</td>
				<td>{$row['points_r']}</td>
				<td>{$row['what_aparat']}</td>
				<td>{$date}</td>
				<td>{$date_end}</td>
				<td>{$quickly}</td>
				<td>{$row['what_master']}</td>
				<td>
					Менеджер: {$userlink_man}<br/>
					Мастер: {$userlink_mast}<br/>
					Выдал: {$userlink}
				</td>
			</tr>	
TPL;
		}
		$GLOBALS['content'] .= '</tbody></table></div>';
	}
	
	function edit_diagnosis_do(){//ajax редактирование поля диагностика
		$query = 'SELECT diagnostik, service FROM orders WHERE id = "'.$_GET['id'].'"';
		$res=mysql_query($query);
		$row=mysql_fetch_array($res);
		
		if($row['id_master'] == $_SESSION['id']){
			$all_bug = $row['diagnostik'].$_GET['newdop'];
			$strSQL = 'UPDATE orders SET diagnostik = "'.$all_bug.'" WHERE id = "'.$_GET['id'].'"';
			mysql_query($strSQL);
		}
		echo $_GET['newdop'];
		exit();
	}
	
	function my_table(){//мой стол
		$GLOBALS['h1'] = 'Мой стол';
		
		$query = "SELECT * FROM orders WHERE bool_ready='0' AND id_master ={$_SESSION['id']} AND refusal=''";
		$sql = mysql_query($query) or die(mysql_error());
		
		$GLOBALS['content'] .= <<<TPL
		<div class="row-fluid">
		<script>
			$(document).ready(function(){
				var oTable = $('#dt_gal').dataTable({
					"sDom": "<'row'>t<'row'<'span4'l><'span4'i><'span4'p>>",
				"sPaginationType": "bootstrap",
					"aaSorting": [[8, "desc"]],
					"aoColumns": [
						{"bSortable": false},
						{"sType": "string"},
						{"sType": "string"},
						{"sType": "string"},
						{"bSortable": false},
						{"bSortable": false},
						{"sType": "string"},
						{"bSortable": false},
						{"sType": "string"},
						{"sType": "string"},
						{"sType": "string"},
						{"bSortable": false},
						{"bSortable": false}
					]
				});
				$('.icon-edit.diagn_edit').live('click', function(){
					var ths = $(this).closest('.diagn_form');
					ths.empty().html('<textarea></textarea><a href="#" class="diagn_btn btn">Дописать</a>');
					$('.diagn_btn').click(function(){
						jQuery.ajax({
							url: '/',
							type: 'GET',
							data: {
								'action': 'edit_diagnosis_do',
								'id': $(this).closest('tr').attr('rel'),
								'newdop': ths.find('textarea').val()
							},
							success: function(data){
								//alert(data);
								ths.closest('td').find('.diagn_info').append(data);
								ths.html('<i class="icon-edit diagn_edit" title="дописать"></i>');
							}              
						});
						return false;
					});
				});
				
				$('.icon-edit.aparat_edit').live('click', function(){
					var ths = $(this).closest('.aparat_form');
					ths.empty().html('<textarea></textarea><a href="#" class="aparat_btn btn">Дописать</a>');
					$('.aparat_btn').click(function(){
						jQuery.ajax({
							url: '/',
							type: 'GET',
							data: {
								'action': 'edit_what_aparat_do',
								'id': $(this).closest('tr').attr('rel'),
								'newdop': ths.find('textarea').val()
							},
							success: function(data){
								//alert(data);
								ths.closest('td').find('.aparat_info').append(data);
								ths.html('<i class="icon-edit aparat_edit" title="дописать"></i>');
							}              
						});
						return false;
					});
				});
			});
		</script>
		<table class="table table-bordered" id="dt_gal">
			<thead> 
				<tr>
					<th>Статус</th>
					<th>№ заказа</th>
					<th>№ в базе</th>
					<th>Сц</th>
					<th>Модель</th>
					<th>Диагностика</th>
					<th>Стоимость</th>
					<th>Балы в рублях</th>
					<th>Что с аппаратом</th>
					<th>Дата приема</th>
					<th>Дата окончания</th>
					<th>Срочно</th>
					<th></th>
					<th></th>
				</tr>
			</thead>
			<tbody>
TPL;

		while($row = mysql_fetch_array($sql)){
			$quickly = 'Нет';
			if($row['bool_quickly'] == 1) {$quickly = 'Да';}
			
			$date = date('d.m.Y H:i', $row['date_admision']);
			if ($row['date_admision'] == 0) {$date = '-';}
			
			$date_end = date('d.m.Y H:i', $row['date_end_remont']);
			if ($row['date_end_remont'] == 0) {$date_end = '-';}
			
			$userlink = get_user_link($row['who_gave']);
			if ($row['who_gave'] == 0) {$userlink = '-';}
			$userlink_man = get_user_link($row['id_menedger']);
			if ($row['id_menedger'] == 0) {$userlink_man = '-';}
			$userlink_mast = get_user_link($row['id_master']); 
			if ($row['id_master'] == 0) {$userlink_mast = '-';}
			
			$status = get_status($row);

			$GLOBALS['content'] .= <<<TPL
			<tr rel="{$row['id']}">
				<td>{$status}</td>
				<td>{$row['numb_order']}<br />{$row['client_name']}</td>
				<td>{$row['numb_order_base']}</td>
				<td>{$row['service']}</td>
				<td>{$row['model']}</td>
				<td><div class="diagn_info">{$row['diagnostik']}</div><div class="diagn_form"><i class="icon-edit diagn_edit" title="дописать"></i></div></td>
				<td>{$row['price']}</td>
				<td>{$row['points_r']}</td>
				<td><div class="aparat_info">{$row['what_aparat']}</div><div class="aparat_form"><i class="icon-edit aparat_edit" title="дописать"></i></div></td>
				<td>{$date}</td>
				<td>{$date_end}</td>
				<td>{$quickly}</td>
				<td>
					Менеджер: {$userlink_man}<br/>
					Мастер: {$userlink_mast}<br/>
					Выдал: {$userlink}
				</td>
				<td>
					<div>
						<a href="/?action=do_bool&id={$row['id']}" class="btn btn-mini btn-success btn_act">Сделал</a>
						<a href="/?action=dont_bool&id={$row['id']}" class="btn btn-danger btn-mini btn_act">Не сделал</a>
						<a href="/?action=dod_but&id={$row['id']}" class="btn btn-inverse btn-mini btn_act">Дополнительно</a>
					</div>
				</td>
			</tr>
TPL;
		}
		$GLOBALS['content'] .= '</table>';
	}
	
	function list_orders(){//все заказы (Очередь на ремонт)
		switch ($_GET['filter']){
		case 'all':
			$GLOBALS['h1'] = "Очередь на ремонт";
			$filter = "";
			break;
		case 'hot':
			$GLOBALS['h1'] = "Очередь на ремонт: срочные заказы";
			$filter = "AND bool_quickly=1";
			break;		
		case 'old':
			$GLOBALS['h1'] = "Очередь на ремонт: долго лежащие заказы";
			$filter = "AND date_admision<100000";
			break;
		case 'search':
			if(isset ($_GET['query'])){
				$GLOBALS['h1'] = 'Поиск "'.$_GET['query'].'" по вашим заказам';
				$query = $_GET['query'];
				$query = trim($query);
				$query = stripslashes($query); 
				$query = htmlspecialchars($query);
				$filter = "AND (numb_order_base LIKE '%{$query}%' OR numb_order LIKE '%{$query}%' OR model LIKE '%{$query}%' OR client_name LIKE '%{$query}%' OR mobile LIKE '%{$query}%')";//Странная ошибка когда буквы
			}
			break;
		default: 
			$GLOBALS['h1'] = "Очередь на ремонт";
			$filter = "";
			break;
		}

		if($_GET['filter'] == 'search'){
			$query = "SELECT * FROM orders WHERE id_master={$_SESSION['id']} AND bool_work=1 {$filter}";
		}else{
			$query = "SELECT * FROM orders WHERE id_master='0' AND date_giving='0' AND refusal='' AND bool_work=1 {$filter}";
		}

		$sql = mysql_query($query) or die(mysql_error());
		
		$GLOBALS['content'] .= <<<TPL
		<div class="row-fluid">
		<script>
			$(document).ready(function(){
				var oTable = $('#dt_gal').dataTable({
					"sDom": "<'row'>t<'row'<'span4'l><'span4'i><'span4'p>>",
					"sPaginationType": "bootstrap",
					"aaSorting": [[8, "desc"]],
					"aoColumns": [
						{"bSortable": false},
						{"sType": "string"},
						{"sType": "string"},
						{"sType": "string"},
						{"bSortable": false},
						{"bSortable": false},
						{"sType": "string"},
						{"bSortable": false},
						{"sType": "string"},
						{"sType": "string"},
						{"sType": "string"},
						{"bSortable": false},
						{"bSortable": false}
					]
				});
				$('.icon-edit.diagn_edit').live('click', function(){
					var ths = $(this).closest('.diagn_form');
					ths.empty().html('<textarea></textarea><a href="#" class="diagn_btn btn">Дописать</a>');
					$('.diagn_btn').click(function(){
						jQuery.ajax({
							url: '/',
							type: 'GET',
							data: {
								'action': 'edit_diagnosis_do',
								'id': $(this).closest('tr').attr('rel'),
								'newdop': ths.find('textarea').val()
							},
							success: function(data){
								//alert(data);
								ths.closest('td').find('.diagn_info').append(data);
								ths.html('<i class="icon-edit diagn_edit" title="дописать"></i>');
							}              
						});
						return false;
					});
				});
			});
		</script>
		<table class="table table-bordered" id="dt_gal">
			<thead> 
				<tr>
					<th>Статус</th>
					<th>№ заказа</th>
					<th>№ в базе</th>
					<th>Сц</th>
					<th>Модель</th>
					<th>Диагностика</th>
					<th>Стоимость</th>
					<th>Балы в рублях</th>
					<th>Что с аппаратом</th>
					<th>Дата приема</th>
					<th>Дата окончания</th>
					<th>Срочно</th>
					<th></th>
					<th></th>
				</tr>
			</thead>
			<tbody>
TPL;

		while($row = mysql_fetch_array($sql)){
			$quickly = 'Нет';
			if($row['bool_quickly'] == 1) {$quickly = 'Да';}
			
			$date = date('d.m.Y H:i', $row['date_admision']);
			if ($row['date_admision'] == 0) {$date = '-';}
			
			$date_end = date('d.m.Y H:i', $row['date_end_remont']);
			if ($row['date_end_remont'] == 0) {$date_end = '-';}
			
			$userlink = get_user_link($row['who_gave']);
			if ($row['who_gave'] == 0) {$userlink = '-';}
			$userlink_man = get_user_link($row['id_menedger']);
			if ($row['id_menedger'] == 0) {$userlink_man = '-';}
			$userlink_mast = get_user_link($row['id_master']); 
			if ($row['id_master'] == 0) {$userlink_mast = '-';}

			$take_but = '';
			if ($row['id_master'] == 0){
				$take_but = '<a href="/?action=take_bool&id='.$row['id'].'" class="btn_act btn btn-mini">Взять</a>';
			}
			
			$do_but = '';
			if ($row['bool_ready']==0 && $row['id_master'] != 0){
				$do_but = '<a href="/?action=do_bool&id='.$row['id'].'" class="btn_act btn btn-mini btn-success">Сделал</a>';
			}
			
			$dont_but = '';
			if ($row['bool_ready']==0 && $row['id_master'] != 0){
				$dont_but = '<a href="/?action=dont_bool&id='.$row['id'].'" class="btn_act btn btn-danger btn-mini">Не сделал</a>';
			}
			
			$dod_but = '';
			if ($row['bool_ready']==0 && $row['id_master'] != 0){
				$dod_but = '<a href="#" class="btn_act btn btn-inverse btn-mini">Дополнительно</a>'; 
			}
			
			$status = get_status($row);
			
			$GLOBALS['content'] .= <<<TPL
			<tr rel="{$row['id']}">
				<td>{$status}</td>
				<td>{$row['numb_order']}<br />{$row['client_name']}</td>
				<td>{$row['numb_order_base']}</td>
				<td>{$row['service']}</td>
				<td>{$row['model']}</td>
				<td><div class="diagn_info">{$row['diagnostik']}</div><div class="diagn_form"><i class="icon-edit diagn_edit" title="дописать"></i></div></td>
				<td>{$row['price']}</td>
				<td>{$row['points_r']}</td>
				<td>{$row['what_aparat']}</td>
				<td>{$date}</td>
				<td>{$date_end}</td>
				<td>{$quickly}</td>
				<td>
					Менеджер: {$userlink_man}<br/>
					Мастер: {$userlink_mast}<br/>
					Выдал: {$userlink}
				</td>
				<td>
					<div>
						
						{$take_but}
						{$do_but}
						{$dont_but}
						{$dod_but}
					</div>
				</td>
			</tr>
TPL;
		}
		$GLOBALS['content'] .= '</tbody></table></div>';	
	}
	
	function dod_but_do(){//додатково
		$diagnostik = $_POST['diagnostik'];
		$id = $_POST['id'];
		$work = $_POST['what'];
		
		$query = 'UPDATE orders SET work="'.$work.'", diagnostik="'.$diagnostik.'" WHERE id="'.$id.'"';
		
		$result = mysql_query($query) or die(mysql_error());
		header("Location: /?action=list_orders", true, 303);
	}
	
	
	function dod_but(){//форма додатково
		$query = ("SELECT * FROM orders WHERE id='{$_GET['id']}'");
		$res=mysql_query($query);
		$row=mysql_fetch_array($res);
		
		$GLOBALS['h1'] = 'Дополнительно - '.$row['numb_order'].' ('.$row['numb_order_base'].')';
		
		$userlink_man = get_user_link($row['id_menedger']);
			if($row['id_menedger'] == 0){$userlink_man = '-';}
		
		$flag = 'Нет';
		if ($row['bool_quickly'] == 1) {$flag = 'Да';}
		
		$date1 = date('d.m.Y', $row['date_admision']);
		$date2 = date('d.m.Y', $row['date_admision_remont']);
		$date3 = date('d.m.Y', $row['date_end_remont']);
		
		$GLOBALS['content'] = <<<HTML
		<form method="post" action="?action=dod_but_do"> 
			<div class="row-fluid">
				<div class="span6">
					<label>Дата приёма</label>
					<input type="text" disabled="disabled" value="{$date1}" class="span12">
				</div>
				<div class="span6">
					<label>Менеджер:</label>
					{$userlink_man}
				</div>
			</div>
			
			<div class="row-fluid">
				<div class="span6">
					<label>Дата согласия</label>
					<input type="text" disabled="disabled" value="{$date1}" class="span12">
				</div>
				<div class="span6">
					<label>Дата приёма на ремонт</label>
					<input type="text" disabled="disabled" value="{$date2}" class="span12">
				</div>
			</div>
			
			<div class="row-fluid">
				<div class="span6">
					<label>Дата окончания ремонта</label>
					<input type="text" name = "date_end_remont" value="{$date3}" class="span12">
				</div>
				<div class="span6">
					<label>Балы</label>
					<input type="text" disabled="disabled" value="{$row['points']}" class="span12">
				</div>
				<div class="span6">
					<label>Балы в рублях</label>
					<input type="text" disabled="disabled" name = "points_r" value="{$row['points_r']}" class="span12">
				</div>
			</div>
			
			<div class="row-fluid">
				<div class="span6">
					<label>Диагностика</label>
					<textarea name = "diagnostik" disabled="disabled" style="height:90px;" class="span12">{$row['diagnostik']}</textarea>
				</div>
				<div class="span6">
					<label>ФИО</label>
					<input type="text" disabled="disabled" name="fio" value="{$row['client_name']}" class="span12">
					<label>Контактный телефон</label>
					<input type="text" disabled="disabled" name="tel" value="{$row['mobile']}" class="span12">
				</div>
			</div>
			
			<div class="row-fluid">
				<div class="span6">
					<label>Стоимость</label>
					<textarea name = "price" disabled="disabled" style="height:90px;" class="span12">{$row['price']}</textarea>
				</div>
				<div class="span6">
					<label>IMEI</label>
					<input type="text" disabled="disabled" name="imei" value="{$row['imei']}" class="span12">
					<label>Срочно</label>
					<input type="text" class="span12" disabled="disabled" name="srochno" value="{$flag}">	
				</div>
			</div>
			
			<div class="row-fluid">
				<div class="span6">
					<label>Неисправность (со слов клиента)</label>
					<textarea   name = "problem" disabled="disabled" style="height:90px;" class="span12">{$row['problem_client']}</textarea>
				</div>
				<div class="span6">
					<label>Что сделал(майстер)</label>
					<textarea  name="what" disabled="disabled" style="height:90px;" class="span12">{$row['work']}</textarea>
				</div>
			</div>
			
			<div class="row-fluid">
				<div style="text-align:right;" class="span6">
					<input type="submit" class="btn btn-large btn-info" value="Сохранить">
					<input type="hidden" name="id" value="{$row['id']}">
				</div>
			</div>
					
	</form>
		
HTML;
			
	}
?>